const express=require('express');
const statics=require('express-static');
const bodyParser=require('body-parser');
const multer=require('multer');
const multerObj=multer({dest:'./www/img'});
const mysql=require('mysql');
const cookieParser=require('cookie-parser');
const cookieSession=require('cookie-session');
const consolidate=require('consolidate');
const ejs=require('ejs');
const expressRoute=require('express-route');

//Router--->node
//route --->express-route
var server=express();
server.listen(8089);

//1.获取请求数据
server.use(multerObj.any());
server.use(bodyParser.urlencoded({extended:false}));
//2cookie
server.use(cookieParser('lkjhgfdsqwertymnbvh'));
//server.use(cookieSession({
//	name:
//	keys:
//	maxAge:
//}));
//3、session
(function(){
<<<<<<< HEAD
  var keys=[];
  for(var i=0;i<100000;i++)
  {
    keys[i]="keys_"+Math.random();
  }
  server.use(cookieSession({
    name:'userName',
    keys:keys,
    maxAge:20*60*1000   //20min
  }));
=======
    var keys=[];
    for(var i=0;i<100000;i++)
    {
        keys[i]="keys_"+Math.random();
    }
    server.use(cookieSession({
        name:'userName',
        keys:keys,
        maxAge:20*60*1000   //20min
    }));
>>>>>>> ac7aaf002e91a3e78236543a10d0b38ade75db96
})();
//路由后台首页idenx
server.use('/forum/',require('./route/forum/index.js')());
//路由后台登录login
server.use('/forum/',require('./route/forum/login.js')());
//路由后台一级论坛
server.use('/forum/',require('./route/forum/PrimaryClassification.js')());
//路由后台论坛一级修改server.use('/forum/',require('./route/forum/updatefouram.js')());
//路由后台修改
server.use('/forum/',require('./route/forum/updatefouram.js')());
server.use('/forum/',require('./route/forum/updatefouram.js')());
//添加分类路由
server.use('/forum/',require('./route/forum/AddPrimaryClassification.js')());



server.use('/forum/',require('./route/forum/forumbinfo.js')());
server.use('/forum/',require('./route/forum/updateforumbinfo.js')());
server.use('/forum/',require('./route/forum/Addforumbinfo.js')());
server.use('/forum/',require('./route/forum/forumcomment.js')());
server.use('/forum/',require('./route/forum/Addforumcomment.js')());
server.use('/forum/',require('./route/forum/updateforumcomment.js')());


//处理模板
server.engine('html',consolidate.ejs);
server.set('views','template');
server.set('view engine','html');


//访问文件
server.use(statics('www'));

